import axios from "axios";

/*
 * @Author: Wxx
 * @Date: 2022-02-26 15:34:36
 * @LastEditors: Wxx
 * @LastEditTime: 2022-02-26 16:48:28
 * @Description:
 */

//使用redux-thunk 返回异步函数
// function saveCinemasList() {
//   return (disatch) => {
//     axios({
//       url: "https://m.maizuo.com/gateway?cityId=510100&ticketFlag=1&k=5195996",
//       headers: {
//         "X-Host": "mall.film-ticket.cinema.list",
//         "X-Client-Info":
//           '{"a":"3000","ch":"1002","v":"5.2.0","e":"16454281163713789501374465","bc":"110100"}',
//       },
//     }).then((res) => {
//       disatch({
//         type: "saveCinemasList",
//         payload: res.data.data.cinemas,
//       });
//     });
//   };
// }

//使用redux-promise 返回一个promise对象
function saveCinemasList() {
  return axios({
    url: "https://m.maizuo.com/gateway?cityId=510100&ticketFlag=1&k=5195996",
    headers: {
      "X-Host": "mall.film-ticket.cinema.list",
      "X-Client-Info":
        '{"a":"3000","ch":"1002","v":"5.2.0","e":"16454281163713789501374465","bc":"110100"}',
    },
  }).then((res) => {
    return {
      type: "saveCinemasList",
      payload: res.data.data.cinemas,
    };
  });
}
export { saveCinemasList };
